from .models import Areas
from rest_framework import serializers


class AreaSerializer(serializers.ModelSerializer):
    """
    行政区序列化器
    """

    class Meta:
        model = Areas
        fields = ['id', 'name']


class SubAreaSerializer(serializers.ModelSerializer):
    """
    子行政区序列化器
    """
    # 反序列化输出时
    subs = AreaSerializer(read_only=True,many=True)

    class Meta:
        model = Areas
        fields = ['id', 'name', 'subs']













